package com.nsl.my_youlai.bbu_return.convert.enums;
import com.nsl.my_youlai.mystar.enums.NslEnumBaseI;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.nsl.my_youlai.bbu_return.enums.ActionEnum;

import com.nsl.my_youlai.common.base.IBaseEnum;

public class ActionEnumConvert implements Converter<ActionEnum> {

    @Override
    public Class<ActionEnum> supportJavaTypeKey() {
        return ActionEnum.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }



    @Override
    public ActionEnum convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {

        return NslEnumBaseI.getEnumByLabel(cellData.getStringValue(),ActionEnum.class);


    }


    //导出时转换
    @Override
    public WriteCellData<ActionEnum> convertToExcelData(ActionEnum value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration)  {

        WriteCellData<ActionEnum> writeCellData=new WriteCellData<>(CellDataTypeEnum.STRING,value.getLabel());
        return writeCellData;
    }
}
